home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Today - The Disc! 8 / cdrt08.iso / mac / Shareware / HyperCard / demoCdef 120 ƒ / demo Source ƒ / panelAssist.c < prev    next >
Encoding:
Text File  |  1994-12-12  |  2.4 KB  |  84 lines  |  [TEXT/KAHL]

  1. //----------------------------------------------------------------------------------
  2. //    File        : panelAssist.c
  3. //    Date        : August 24, 1994
  4. //    Author        : Jim Stout
  5. //    Purpose        : Some utility routines for use with the tabPanel CDEF.
  6. //
  7. //----------------------------------------------------------------------------------
  8. #include "dialogAssist.h"
  9. #include "panelAssist.h"
  10.  
  11. //----------------------------------------------------------------------------------
  12. //    Function: panelSwap
  13. //     Purpose: change a dialog panel in a dialog that uses the tabPanel CDEF.
  14. //
  15. //    NOTE: This routine assumes that the CountDITL, AppendDITL & ShortenDITL are
  16. //            available. (System 7 or CommToolbox is installed);
  17. //
  18. //   returns: void
  19. //----------------------------------------------------------------------------------
  20.  
  21. extern void panelSwap(DialogPtr theDialog, short fromPanel, short toPanel, short DITLbase)
  22. {    
  23.     Handle            h;
  24.     short            toRemove=0;
  25.  
  26.     toRemove = CountDITL(theDialog) - DITLbase;
  27.         
  28.     h = GetResource('DITL', 128+toPanel);
  29.     if(h) {
  30.         if(toRemove)
  31.             ShortenDITL(theDialog, toRemove);
  32.         AppendDITL(theDialog, h, overlayDITL);
  33.         ReleaseResource(h);
  34.     }
  35.     else {
  36.         ShortenDITL(theDialog, toRemove);
  37.         toRemove = 0;
  38.     }
  39.     
  40. }
  41.  
  42. //----------------------------------------------------------------------------------
  43. //    Function: panelCmdKey
  44. //     Purpose: allow a cmd-key to operate the tabPanel CDEF.
  45. //
  46. //   returns: void
  47. //----------------------------------------------------------------------------------
  48.  
  49. extern Boolean panelCmdKey(DialogPtr theDialog, short panelID, char c, short *theItem)
  50. {
  51.     short    num;
  52.     
  53.      num = daGetCtlMax(theDialog, panelID) + 0x30;
  54.      if(c >= 0x31 && c <= num) {
  55.          num = c - 0x30;
  56.          daSetCtlValue(theDialog, panelID, num);
  57.          *theItem = panelID;
  58.          return(TRUE);
  59.      }
  60.      return(FALSE);
  61. }
  62. //----------------------------------------------------------------------------------
  63. //    Function: panelCmdTab
  64. //     Purpose: allow a cmd-tab to cycle thru tabs on the tabPanel CDEF.
  65. //
  66. //   returns: void
  67. //----------------------------------------------------------------------------------
  68.  
  69. extern Boolean panelCmdTab(DialogPtr theDialog, short panelID, char c, short *theItem)
  70. {
  71.     short    max,val;
  72.     
  73.      max = daGetCtlMax(theDialog, panelID);
  74.      val = daGetCtlValue(theDialog, panelID);
  75.      if(c == _TAB) {
  76.          val++;
  77.          if(val > max)
  78.              val = 1;
  79.          daSetCtlValue(theDialog, panelID, val);
  80.          *theItem = panelID;
  81.          return(TRUE);
  82.      }
  83.      return(FALSE);
  84. }